package com.browsesoft.htmlcomponent;

import java.util.Hashtable;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.browsesoft.dbtools.DBTools;

public class HTMLMailDBFormModel extends HTMLDBFormModel implements
		HTMLFormModel {
	private String userid = new String();

	/**
	 * 更新属性
	 * 
	 * @param ht
	 *            存储属性的哈息表
	 */
	public void updateAttributes(Hashtable ht) throws Exception {
		// 设置父ID
		attributes.put("processid", userid);
		attributes.put("userid", userid);
		String[][] result = DBTools.executeQueryWithTableHead("select * from "
				+ tableName + " where id=" + (String) attributes.get("id"));
		if (result.length == 1) {
			DBTools.insert(tableName, attributes);
		}
		if (result.length == 2) {
			DBTools
					.update(tableName, (String) attributes.get("id"),
							attributes);
		}
		parentID = null;
		// 更新
		this.attributes.putAll(ht);
		DBTools.update(tableName, (String) attributes.get("id"), attributes);
	}

	public void service(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		super.service(request, response);
	}
}
